home *** CD-ROM | disk | FTP | other *** search
-
-
-
- ppppoooollllllll((((7777)))) ppppoooollllllll((((7777))))
-
-
-
- NNNNAAAAMMMMEEEE
- poll - device for high speed poll on file descriptors
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttrrrrooooppppttttssss....hhhh>>>>
- ####iiiinnnncccclllluuuuddddeeee <<<<ppppoooollllllll....hhhh>>>>
- ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ddddeeeevvvvppppoooollllllll....hhhh>>>>
-
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- /dev/poll is a device that allows users to efficiently monitor large
- numbers of file descriptors. /dev/poll works similarly to the _p_o_l_l
- system call and to the Sun Solaris version of the device except as noted
- below. File descriptors to be polled are registered and scanned with the
- _w_r_i_t_e and _i_o_c_t_l system calls respectively.
-
- Registration of file descriptors is done by writing an array of pollfd
- structures to the /dev/poll device. These structures are handled the
- same as in _p_o_l_l and contain the following fields:
-
- int fd; /* file descriptor */
- short events; /* requested events */
- short revents; /* returned events */
-
- Each passed pollfd is cached within the /dev/poll device. If a previous
- pollfd is found referencing the same file descriptor, their events fields
- are combined. Users wishing to maintain separate sets of registered
- pollfd structures should open separate instances of the /dev/poll device.
- The _w_r_i_t_e call returns the number of bytes written or -1 and an error
- code. Following a pollfd's registration, the device watches for the
- events specified in the structure's events field to occur to the file
- descriptor specified in the structure's fd field.
-
- Event notification is received through the _i_o_c_t_l system call using the
- DDDDPPPP____PPPPOOOOLLLLLLLL command with a pointer to a dvpoll structure as its argument.
- The dvpoll structure has the following fields:
-
- struct pollfd * dp_fds; /* pollfd array */
- nfds_t dp_nfds; /* Number of pollfds at dp_fds */
- int dp_timeout; /* Time-out in milliseconds */
-
- dp_fds is an array to which up to dp_nfds pollfds with active events will
- be copied by the device. Each copied pollfd's revents field will include
- those events in the events field that are active. Each pollfd's fd field
- will be set to the file descriptor that it was monitoring, and its events
- field will be set to the events that it's watching for. If no active
- events are found, the call will block for the length of time in
- dp_timeout. If dp_timeout is 0 then the call will immediately return.
- If dp_timeout is -1 then the call will block until a registered event
- does become active. If dp_timeout is greater than 0 then it will block
- for that many milliseconds unless an event becomes active. The _i_o_c_t_l
- will return either the number of pollfds received, or -1 if an error
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- ppppoooollllllll((((7777)))) ppppoooollllllll((((7777))))
-
-
-
- occurred.
-
- A user can unregister pollfds from the device's poll set by adding the
- PPPPOOOOLLLLLLLLRRRREEEEMMMMOOOOVVVVEEEE flag to the events field of a pollfd and writing it to the
- device. When a monitored file descriptor is closed, all /dev/poll
- instances that had pollfds registered to monitor it will stop monitoring
- the file. The pollfds will remain cached in the /dev/poll device and can
- be removed with the PPPPOOOOLLLLLLLLRRRREEEEMMMMOOOOVVVVEEEE flag as described above. If a new file or
- socket is opened with a file descriptor that is the same as a previously
- closed file or socket that had a registered pollfd that is still cached
- in a /dev/poll instance, the registered pollfd will not monitor the new
- file or socket. If a pollfd is written to one of these /dev/poll
- instances to monitor this new file or socket, it will overwrite the no
- longer used previous pollfd.
-
- Users may use the DDDDPPPP____RRRREEEEMMMMOOOOVVVVEEEE _i_o_c_t_l command on a /dev/poll instance to
- direct the device to try to remove cached pollfds from the device
- instance whenever the file descriptor that they are watching is closed.
- The device instance will only attempt this while doing other work and it
- may not always be successful.
-
- Users may use the DDDDPPPP____IIIISSSSPPPPOOOOLLLLLLLLEEEEDDDD _i_o_c_t_l command with a pollfd as the argument
- to check if the file descriptor specified in the pollfds fd field is part
- of the poll set for the /dev/poll instance queried. The _i_o_c_t_l returns 1
- if the file descriptor is part of the poll set, and returns the currently
- polled events in the pollfd's events field. The call returns 0 if the
- file descriptor is not being polled and -1 if there was an error.
-
- When a program with an open instance of /dev/poll issues the _f_o_r_k system
- call to create a child process, or _s_p_r_o_c to create a child with a non-
- shared file descriptor table, any attempts by the child to _w_r_i_t_e or use
- _i_o_c_t_l on the instance will fail with the EEEEAAAACCCCCCCCEEEESSSS error code. It is
- suggested that child processes close the instance and open a new one.
- When the last open reference to an instance is closed, all cached pollfds
- will be removed as well.
-
- NNNNOOOOTTTTEEEESSSS
- In the Sun Solaris version of /dev/poll, when a file descriptor is closed
- that has /dev/poll pollfds monitoring it, and a new file is opened with
- the same file descriptor, the pollfds will switch to monitor the new
- file. The IRIX version is different in that the pollfds will not switch
- to monitor the new file descriptor. They will remain dormant in their
- /dev/poll instances until they are overwritten with new pollfds
- referencing the file descriptor or they are removed with PPPPOOOOLLLLLLLLRRRREEEEMMMMOOOOVVVVEEEE.
-
- HHHHIIIISSSSTTTTOOOORRRRYYYY
- The /dev/poll device was added in IRIX 6.5.15.
-
- SSSSEEEEEEEE AAAALLLLSSSSOOOO
- fork(2), ioctl(2), poll(2), sproc(2), write(2).
-
-
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- ppppoooollllllll((((7777)))) ppppoooollllllll((((7777))))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-
-
-
-